﻿Partial Public Class OptionsPage

    Private Sub OptionsPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        cbxRequireConnection.IsChecked = My.Settings.RequireConnection
        cbxAutoResizeMap.IsChecked = My.Settings.AutoResizeMap
        GetPushpinSetting()

        Dim fname As String
        fname = SpatialAlbum.VirtualEarthMap.My.MySettings.Default.RTS_BlueIcon
        fname = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location), fname)
        imgBluePin.Source = New BitmapImage(New Uri(fname))

        fname = SpatialAlbum.VirtualEarthMap.My.MySettings.Default.RTS_RedIcon
        fname = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location), fname)
        imgRedPin.Source = New BitmapImage(New Uri(fname))
    End Sub

    Private Sub GetPushpinSetting()
        Select Case My.Settings.Pushpin
            Case VirtualEarthMap.EnumIcon.eBlue : rdoBlue.IsChecked = True
            Case VirtualEarthMap.EnumIcon.eRed : rdoRed.IsChecked = True
            Case Else : rdoDefault.IsChecked = True
        End Select
    End Sub

    Private Sub cbxRequireConnection_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles cbxRequireConnection.Checked, cbxRequireConnection.Unchecked
        My.Settings.RequireConnection = cbxRequireConnection.IsChecked
        My.Settings.Save()
    End Sub

    Private Sub cbxAutoResizeMap_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles cbxAutoResizeMap.Checked, cbxAutoResizeMap.Unchecked
        My.Settings.AutoResizeMap = cbxAutoResizeMap.IsChecked
        My.Settings.Save()
        Try
            Dim map As SpatialAlbum.VirtualEarthMap.IMapControl = PageManager.Page(EnumPage.ePhotos).MapControl
            map.AutoResize = My.Settings.AutoResizeMap
        Catch : End Try
        'Try
        '    Dim map As SpatialAlbum.VirtualEarthMap.IMapControl = PageManager.Page(EnumPage.ePhotos2).MapControl
        '    map.AutoResize = My.Settings.AutoResizeMap
        'Catch : End Try
    End Sub

    Private Sub pushpin_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles rdoBlue.Checked, rdoRed.Checked, rdoDefault.Checked
        If sender Is rdoBlue Then
            VirtualEarthMap.Icon = VirtualEarthMap.EnumIcon.eBlue
        ElseIf sender Is rdoRed Then
            VirtualEarthMap.Icon = VirtualEarthMap.EnumIcon.eRed
        Else
            VirtualEarthMap.Icon = VirtualEarthMap.EnumIcon.eDefault
        End If
        My.Settings.Pushpin = VirtualEarthMap.Icon
        My.Settings.Save()
    End Sub

End Class
